import requests
from bs4 import BeautifulSoup
headrs = {'User-Agent':'Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)'}
url = "https://html-color-codes.info/color-names/"
r = requests.get(url, headers =headrs)
r.encoding=r.apparent_encoding
soup = BeautifulSoup(r.text, 'lxml')
trs = soup.find_all('tr') # 获取全部tr标签成为一个列表
for tr in trs:    # 遍历列表里所有的tr标签单项
 style = tr.get('style') # 获取每个tr标签里的属性style
 tds = tr.find_all('td') # 将每个tr标签下的td标签获取为列表
 td = [x for x in tds] # 获取的列表
 name = td[1].text.strip()  # 直接从列表里取值
 colorvalue= td[2].text.strip()
 # count=0
 # for d in tds:
 #  if count==0 or count==3:
 #   count+= 1
 #  elif count==1:
 #   name = d.text.strip()
 #   count += 1
 #  elif count==2:
 #   colorvalue= d.text.strip()
 #   count += 1

 print(name, colorvalue, style)